<?php

/*
 * for ajax call
 */

class DoController extends App_Controller_Action
{

    public function init()
    {
    	$this->_helper->layout->disableLayout();
    }

    public function indexAction()
    {
    	
    	$result['success'] = true;
    	$this->_helper->json($result);
    }

    
	public function getUserAction()
	{
		$model_user = new Model_UserAdmin();
		
		$request = $this->getRequest();
		
		$id = $request->getParam('id');
		
		$userInfo = $model_user->getUser($id);
		
		$this->_helper->json($userInfo);		
	}
    
	public function getServiceAction()
	{
		$model_service = new Model_Service();
				
		$request = $this->getRequest();
		
		$dpt_id = $request->getParam('dpt_id');
		
		$serviceInfo = $model_service->getServiceInfo($dpt_id);
		
		$this->_helper->json($serviceInfo);		
	}
	
	public function getNewsAction()
	{
		$model_user = new Model_UserAdmin();
		
		$request = $this->getRequest();
		
		$id = $request->getParam('id');
		
		$newsInfo = $model_user->getNews($id);
		
		$this->_helper->json($newsInfo);		
	}
    
	public function getMessageAction()
	{
		$model_user = new Model_UserAdmin();
		
		$request = $this->getRequest();
		
		$id = $request->getParam('id');
		
		$messageInfo = $model_user->getMessage($id);
		
		$this->_helper->json($messageInfo);		
	}
	
	public function shareAction()
	{
		$model_user = new Model_UserClient();
						
		$request = $this->getRequest();
		
		$dpt_id = $request->getParam('dpt_id');
		$dpt_account_id = $request->getParam('dpt_account_id');
		$client_id = $request->getParam('client_id');
		$share_to = $request->getParam('share_to');
		
		$shareInfo = $model_user->shareClientService($client_id,$dpt_id,$dpt_account_id,$share_to);
		$this->_helper->json($shareInfo);		
	}
	
	public function getShareAction()
	{
		$model_user = new Model_UserClient();
						
		$request = $this->getRequest();
		
		$dpt_id = $request->getParam('dpt_id');
		$dpt_account_id = $request->getParam('dpt_account_id');
		$client_id = $request->getParam('client_id');
		
		$shareInfo = $model_user->getClientShareService($client_id,$dpt_id,$dpt_account_id);
		
		if (!$shareInfo){
			$shareInfo=array();
		}
		$this->_helper->json($shareInfo);		
	}

	public function removeShareAction()
	{
		$model_user = new Model_UserClient();
						
		$request = $this->getRequest();
		
		$dpt_id = $request->getParam('dpt_id');
		$dpt_account_id = $request->getParam('dpt_account_id');
		$client_id = $request->getParam('client_id');
		$share_from = $request->getParam('share_from');
		
		$shareInfo = $model_user->removeClientShareService($client_id,$dpt_id,$dpt_account_id,$share_from);
		
		$this->_helper->json($shareInfo);		
	}
	
	public function getManagerAction()
	{
		$model_user = new Model_UserClient();
		
		$request = $this->getRequest();
		
		$id = $request->getParam('id');
		
		$managerInfo = $model_user->getManager($id);		
		
		$this->_helper->json($managerInfo);		
	}
	
}
